﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<%@include file="/common/javascript.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>作业批改</title>
    <script type="text/javascript">
    var mainform;
    var viewType = "${viewType}";
	var dialog=null;
	var terDialog=null;
	
    $(function (){
    	
        mainform=$("#mainform");
        
        mainform.ligerForm();
        
        //如果是修改视图,主键不可编辑
        if(viewType=="modify"){
        	 $("#id").attr("readonly", "readonly").removeAttr("validate");
        }
        
        //如果是详细试图,所有字段不可编辑
        if(viewType=="detail"){
        	$("input,select,textarea",mainform).attr("readonly", "readonly");
        }else{
            $.metadata.setType("attr", "validate");
            LG.validate(mainform);
        }
        
        //渲染按钮
        LG.setFormDefaultBtn(cancel,viewType=="detail" ? null : save);
        
        //调整form-bar
        $(".form-bar").css("width","800px");        

    });
   
    function save(){
        LG.submitForm(mainform, function (result) {
        	if(typeof(result)=="string"){
        		result=eval("("+result+")");
        	}
            if (!result.success) {
                LG.showError('错误:' + result.message);
            }
            else { 
                LG.showSuccess('保存成功', function () { 
                   LG.callParent("homeworkSubmitList");
                });
            }
        });
    }
    function cancel(){
        var win = window.parent || window;
        if(win.dialog){
        	win.dialog.close();
        }
    }

 </script>
</head>

<body>
    <form name="mainform" method="post"  id="mainform" action="${ctx}/qso/homeworkSubmit/doCorrect">
        <input type="hidden" name="viewType" value="${viewType}"/>
        <input type="hidden" id="id" name="id" value="${command.id}"/>
        <input type="hidden" id="courseId" name="courseId" value="${command.course.id}"/>
        <input type="hidden" id="studentId" name="studentId" value="${command.student.stuId}"/>
        <input type="hidden" id="teacherId" name="teacherId" value="${command.teacher.terId}"/>
        <input type="hidden" id="homeworkHId" name="homeworkHId" value="${command.homeworkH.id}"/>
        <input type="hidden" id="description" name="description" value="${command.description}"/>
        <input type="hidden" id="hwkStatus" name="hwkStatus" value="CO" />
        <table cellpadding="0" cellspacing="0" class="l-table-edit" style="width: 95%; margin-top:10px; margin-left:15px;">     
            <tr>
                <td align="right" class="l-table-edit-td">作业编号:</td>
                <td align="left" class="l-table-edit-td" colspan="3">
						${command.id}
                </td>
            </tr>
            <tr>
                <td align="right" class="l-table-edit-td">提交作业名称:</td>
                <td align="left" class="l-table-edit-td" >
                	<input disabled="disabled"  type="text" id="homeworkName" name="homeworkName" value="${command.homeworkName}" validate="{required:true}"/>
                </td>
                <td align="right" class="l-table-edit-td">作业题目:</td>
                <td align="left" class="l-table-edit-td" >
                	<input  type="text"  disabled="disabled"  id="hwkhTitle" name="hwkhTitle" value="${command.homeworkH.title}"  validate="{required:true}"/>
                </td>
            </tr>
			<tr>
				<td align="right" class="l-table-edit-td" valign="top">选择附件:</td>
				<td align="left" class="l-table-edit-td" >
					<table class="l-table-edit-td">
					<c:choose>
					<c:when test="${not empty command.hwkAttachmentList}">
						<c:forEach  items="${command.hwkAttachmentList}" var="hwkFile"  varStatus="status">
							<c:choose>
							<c:when test="${not empty hwkFile.filePath}">
								<tr>
								<td align="left" class="l-table-edit-td" >
								<div id="deFile_${hwkFile.id}" class="l-table-edit-td">
									${hwkFile.filePath} <a href="${ctx}/qso/homeworkSubmit/download?hwkAttachmentId=${hwkFile.id}">下载</a>	
								</div>
								</td>
								</tr>
							</c:when>
							<c:otherwise>
							<tr>
								<td align="left" class="l-table-edit-td" colspan="3">
								<div id="upFile_${hwkFile.id}" <c:if test="${not empty hwkFile.filePath}">style="display:none" </c:if> />
								</td>
							</tr>
							</c:otherwise>
							</c:choose>
						</c:forEach>
					</c:when>
					</c:choose>
					</table>
				</td>
            	<td align="right"  class="l-table-edit-td">内容:</td>
                <td align="left" class="l-table-edit-td" >
                	<textarea class="l-textarea" id="descriptionDiv" name="descriptionDiv" style="width:400px" disabled="disabled">${command.description}</textarea>
                </td>
            </tr>
            <tr>
            	<td align="right" class="l-table-edit-td">作业评分:</td>
                <td align="left" class="l-table-edit-td" >
                	<input  type="text" id="hwkGrade" name="hwkGrade" value="${command.hwkGrade}" validate="{required:true}"/>
                </td>
                <td align="right" class="l-table-edit-td">作业评语:</td>
                <td align="left" class="l-table-edit-td"  >
                	<textarea cols="200" rows="3"  class="l-textarea" id="hwkComment" name="hwkComment" style="width:400px"  validate="{required:true}">${command.hwkComment}</textarea>
                </td>
            </tr>
        </table> 
    </form>
</body>
</html>